Skip to content

BREAKING: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer#176

Merged
layershifter merged 2 commits into
microsoft:mainfrom
layershifter:perf/drop-keyborg-props
May 21, 2026
Merged

BREAKING: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer#176
layershifter merged 2 commits into
microsoft:mainfrom
layershifter:perf/drop-keyborg-props

Conversation

@layershifter

@layershifter layershifter commented May 18, 2026

Copy link
Copy Markdown
Member

Summary

KeyborgProps was the only argument to createKeyborg/createKeyborgCore, gating two opt-in features:

  • triggerKeys — a custom set of key codes that should enter keyboard-navigation mode in place of the default predicate (any non-Tab key on a non-editable element). No known consumer passes a custom set; the default already covers screen-reader and Tab-driven flows.
  • dismissKeys — a key set that scheduled a 500 ms timer to dismiss keyboard mode if focus did not move (typically wired to Escape). This hand-rolled latch duplicated work consumers already do at the application level.

Drops:

  • the KeyborgProps interface,
  • the triggerKeys / dismissKeys Set construction,
  • shouldDismiss / scheduleDismiss / dismissTimer / _dismissTimeout,
  • the triggerKeys membership check in shouldTrigger,
  • the dismiss-timer cleanup branch in dispose.

onKeyDown collapses to a single guard:

const onKeyDown = (e: KeyboardEvent): void => {
  if (!isNavigating && shouldTrigger(e)) {
    setNavigating(true);
  }
};

Public API impact

  • createKeyborg(win, props?)createKeyborg(win).
  • KeyborgProps type is removed.

KeyborgProps was never re-exported from src/index.mts, so it was only reachable via deep imports. Callers passing the second argument hit a type error; callers passing nothing are unaffected. Worth a minor or major bump depending on how strict the maintainers want to be.

🤖 Generated with Claude Code

KeyborgProps was the only argument to `createKeyborg`/`createKeyborgCore`,
gating two features:

* `triggerKeys` — a custom set of keys that should opt the window into
  keyboard-navigation mode in place of "any non-Tab key on a non-editable
  element". Never used by any known consumer; the default predicate is
  already the right behaviour for screen-reader and Tab-driven flows.
* `dismissKeys` — a key set that scheduled a 500 ms timer to dismiss
  keyboard mode if focus did not move (typically wired to Escape). This
  hand-rolled latch duplicated work consumers already do at the
  application level.

Drop the props interface, the `shouldDismiss`/`scheduleDismiss`/
`dismissTimer`/`_dismissTimeout` machinery, and the `triggerKeys`
membership check in `shouldTrigger`. `onKeyDown` collapses to a single
guard: enter keyboard mode if not already in it and the key should
trigger.

`KeyborgProps` was never re-exported from `src/index.mts`, so the public
surface stays compatible aside from the (still-typed) extra `createKeyborg`
parameter going away.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
keyborg
All exports
3.765 kB
1.557 kB
3.375 kB
1.415 kB
-390 B
-142 B
keyborg
createKeyborg() & disposeKeyborg()
3.597 kB
1.514 kB
3.207 kB
1.373 kB
-390 B
-141 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
keyborg
KEYBORG_FOCUSIN constant
64 B
80 B
🤖 This report was generated against f3fa4681f07259073643f32eddaf55e6fa0ca36d

@layershifter layershifter changed the title perf: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer BREAKING: drop KeyborgProps (triggerKeys/dismissKeys) and dismiss timer May 18, 2026
@layershifter
layershifter marked this pull request as ready for review May 18, 2026 10:34
@layershifter
layershifter requested review from a team and mshoho as code owners May 18, 2026 10:34
@layershifter
layershifter merged commit d9b9608 into microsoft:main May 21, 2026
3 checks passed
@layershifter
layershifter deleted the perf/drop-keyborg-props branch May 21, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants